# 编写自动化测试用例
import unittest
from selenium import webdriver
from time import sleep
from login.oa import login
class Myfile(unittest.TestCase):
    def setUp(self) -> None:  # 初始化，前置条件里面做的事 -> 返回值建议符
        self.driver = login()
        # self.driver = webdriver.Firefox()
        # self.driver.get(r'http://127.0.0.1:8080/oa/')
        # self.driver.implicitly_wait(5)
        # self.driver.maximize_window()
        # self.driver.find_element('name','loginId').send_keys('admin')
        # self.driver.find_element('name','password').send_keys('sys123456')
        # self.driver.find_element('id','button_submit').click()## 登录进入oa系统

    def test001(self): #我的日志
        self.driver.find_element('xpath','/ html / body / div[2] / div / h3[5] / a').click()#点击工作记录
        self.driver.find_element('xpath','/html/body/div[2]/div/div[5]/table/tbody/tr[2]/td/a/img').click()#点击我的日志
        self.driver.switch_to.frame(self.driver.find_element('id','iframe_main')) ##进入输入我的日志的html页面
        ele1=self.driver.find_elements('xpath','/ html / body / form[1] / div[2] / div / div[1] / div[2] / table / tbody / tr')
        self.driver.find_element('xpath','/html/body/form[1]/div[1]/div[1]/button').click()#点击新增
        self.driver.switch_to.default_content()  ##切回最外层
        self.driver.switch_to.frame(self.driver.find_element('xpath','/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/iframe')) ##进入新增弹窗
        self.driver.find_element('id','summary').send_keys('这个是摘要')
        self.driver.switch_to.frame(self.driver.find_element('id','baidu_editor_0')) #进入输入内容页面
        self.driver.find_element('xpath','/html').send_keys('这个是内容')
        self.driver.switch_to.parent_frame()
        self.driver.find_element('id','button_send').click()#点击提交
        self.driver.switch_to.default_content()
        self.driver.find_element('xpath','/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[3]/td/div/input').click()#点击确定
        self.driver.switch_to.default_content()
        ele2=self.driver.find_elements('xpath','/ html / body / form[1] / div[2] / div / div[1] / div[2] / table / tbody / tr')
        self.assertNotEqual(ele1,ele2,msg='提交失败')
    def tearDown(self) -> None:
        sleep(5)
        self.driver.close()
# 执行测试用例
if __name__ == '__main__':
    unittest.main()